/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                                                           *
 *                          Copyright (c) 2010                               *
 *                  Alen Stojanov [ ioi.alen@gmail.com ]                     *
 *                Jacobs University Bremen, Bremen, Germany                  *
 *                                                                           *
 *                          All Rights Reserved.                             *
 *                                                                           *
 *    Permission to use, copy, modify and distribute this software and       *
 *    its documentation is hereby granted, provided that both the            *
 *    copyright notice and this permission notice appear in all copies of    *
 *    the software, derivative works or modified versions, and any           *
 *    portions thereof, and that both notices appear in supporting           *
 *    documentation.                                                         *
 *                                                                           *
 *    This code is distributed in the hope that it will be useful, but       *
 *    WITHOUT ANY WARRANTY; without even the implied warranty of             *
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS       *
 *    DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER          *
 *    RESULTING FROM THE USE OF THIS SOFTWARE.                               *
 *                                                                           *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <QtGui>
#include <QFile>
#include <QApplication>
#include <QVector>
#include <QMetaType>

#include "tsrenderer.h"
#include "tsdata.h"

/////////////////////////////////////////////////////////
// Generate stupid input
/////////////////////////////////////////////////////////
void generate_dummy_input ()
{
	qsrand(0);
	for ( int j = 0; j < 300; j++) {
		QFile dummy("dummy" + QString::number(j) + ".txt");
		if (dummy.exists()) {
			return;
		}
		dummy.open(QIODevice::WriteOnly);
		for ( long i = 0; i < 10000L; i++ ) {
			int x = (int)( qrand() / (double)RAND_MAX * 1000 );
			QString line = QString::number(i) + " " + QString::number(x) + "\n";
			dummy.write(line.toAscii());
		}
		dummy.close();
	}
}
/////////////////////////////////////////////////////////

/**
 * @brief Register all required Qt types
 *
 * Qt need to know in advanced of all the application types
 * in order to ensure signal-slot connections between Q_OBJECTs
 */
void register_types ()
{
	qRegisterMetaType< QVector<TSData*> >("QVector<TSData*>");
}

/**
 * @brief Main program entry
 */
int main(int argc, char *argv[])
{
	/* generate dummy input file */
	// generate_dummy_input();

	/* register all the types used in the application */
	register_types();

	/* start the application */
	QApplication a(argc, argv);
    TSRenderer w;
    w.show();
    return a.exec();
}
